﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SlgHeroStateMove : NState<SlgEntityHero>
{
    public void Enter(SlgEntityHero entity, params object[] args)
    {
        MoveComp.moveType moveEnum = (MoveComp.moveType)args[0];
        string moveClipName = args[1] as string;
        bool isLoop = (bool)args[2];
        Vector3 pos = Vector3.zero;
        if (moveEnum == MoveComp.moveType.Acceleration)
        {
            Vector3 dir = (Vector3)args[3];
            pos = (Vector3)args[4];
            entity.m_pMoveComp.AccelerationMove(10, dir, pos);
        }
        else if (moveEnum == MoveComp.moveType.Uniform)
        {
            float speed = (float)args[3];
            pos = (Vector3)args[4];
            entity.m_pMoveComp.UniformMove(speed, pos);
        }
        entity.PlayAction(moveClipName, isLoop);
        Vector3 moveDir = (pos - entity.m_pGameObj.transform.position).normalized;
        if (moveDir.x > 0)
            entity.m_pSkele.skeleton.FlipX = entity.m_pHeroVo.m_bFilp ? !entity.m_pHeroVo.m_bFilp : entity.m_pHeroVo.m_bFilp;
        else
            entity.m_pSkele.skeleton.FlipX = entity.m_pHeroVo.m_bFilp ? entity.m_pHeroVo.m_bFilp : !entity.m_pHeroVo.m_bFilp;
    }

    public void Execute(SlgEntityHero entity, params object[] args)
    {
        
    }

    public void Exit(SlgEntityHero entity, params object[] args)
    {
        entity.m_pMoveComp.StopMove();
    }

    public bool OnMessage(SlgEntityHero entity, MessageBody message)
    {
        return false;
    }
}
